home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / SAT 2.3.8 / Demos / FastLoad Demo ƒ / FastLoadDemo.c < prev    next >
C/C++ Source or Header  |  1996-06-23  |  2KB  |  81 lines

  1.  
  2. /*  C translation from Pascal source file: FastLoadDemo.p */
  3.  
  4.  
  5. //• main FastLoadDemo;
  6.  
  7. /*A demo/test program showing how to load a large number of faces from PICT resources with*/
  8. /*minimal overhead. There are some parts missing - row start tables to be precise - and you*/
  9. /*could possibly take the mask regions out. It all depends on your needs. If you plan to use SAT's*/
  10. /*blitters all the time (i.e. SATRun(true) you can remove the regions.*/
  11.  
  12. /*This program will ONLY work in 256 colors or more! In B/W or 4-bit color, there are additional*/
  13. /*data needed since SAT does certain special optimizing for those depths. I have tested it in 256*/
  14. /*and thousands of colors, and it will probably run out of memory in millions.*/
  15.  
  16. /*This program does no error checking! You will have to add that to use it in a real program!*/
  17.  
  18. /*/Ingemar Ragnemalm december 1995*/
  19. /*Revised may 1996, in order to clean up, add more options, and make FaceLoad a stand-alone*/
  20. /*reusable module.*/
  21.  
  22. /* C version by Ingemar june -96 */
  23. /* Note: if you make a PPC project out of this, use 68k struct alignment. */
  24.  
  25. #include "SAT.h"
  26. #include "FastLoad.h"
  27.  
  28.  
  29. pascal void Nop(SpritePtr me);
  30. pascal void Nop(SpritePtr me){}
  31.  
  32. void main(void)
  33. {
  34.     struct Sprite ppsprite;
  35.     SpritePtr sptr;
  36.  
  37.     FacePtr faces;
  38.  
  39.     short h, v;
  40.  
  41.     SATInitToolbox();
  42.  
  43.     SATInit(128, 128, 400, 300);
  44.  
  45. /*Load the faces!*/
  46.     SysBeep(1);
  47.     faces = Load2DFaceArray(129, 130, 100, 32, 32, 10, true, true);
  48.     SysBeep(1);
  49.  
  50. /*I use SATNewSpritePP here. That has no connection to the face loading - I could just as well*/
  51. /*use SATNewSprite as usual! Consider this a little demonstration of SATNewSpritePP thrown in*/
  52. /*"for free".*/
  53.     sptr = SATNewSpritePP(nil, (char *)&ppsprite, 0, 0, 0, nil);
  54.     ppsprite.task = &Nop;
  55.     ppsprite.face = nil;
  56.     ppsprite.face = SATGetFace(128);
  57.  
  58.     SATSetPortScreen();
  59.     HideCursor();
  60.     while ( ! Button () )
  61.         {
  62. /*Set the face of the sprite to one of the 100 sprites in the faces array, depending on mouse position.*/
  63.             GetMouse(&ppsprite.position);
  64.  
  65.             h = ppsprite.position.h * 10 / gSAT.offSizeH;
  66.             if ( h < 0 )
  67.                 h = 0;
  68.             if ( h > 9 )
  69.                 h = 9;
  70.             v = ppsprite.position.v * 10 / gSAT.offSizeV;
  71.             if ( v < 0 )
  72.                 v = 0;
  73.             if ( v > 9 )
  74.                 v = 9;
  75.             ppsprite.face = &faces[h + v * 10];
  76.  
  77.             SATRun(false);
  78.         };
  79.     ShowCursor ();
  80. }
  81.